package org.iteye.bbjava.action;

import java.util.Map;

import org.iteye.bbjava.frame.work.utils.Struct2Util;
import org.iteye.bbjava.model.User;
import org.iteye.bbjava.service.RegisterService;
import org.springframework.util.StringUtils;

import com.opensymphony.xwork2.ActionSupport;

public class SysSafeAction  extends ActionSupport {
	
	public User user;
	private RegisterService registerService;
	
	private void regiest(User user){
		Map<String,String> map = Struct2Util.getReuqestParams();
		user.setEmail(map.get("eMail"));
		user.setName(map.get("userName"));
		user.setPassword(map.get("password"));
		int successFlag = registerService.regest(user);
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}


	
	public RegisterService getRegisterService() {
		return registerService;
	}

	public void setRegisterService(RegisterService registerService) {
		this.registerService = registerService;
	}

	/**
	 * 检查是否存在
	 */
	private void checkExist(){
		registerService.getPwdByAnswerAndQuestion(user);
	}
	
	public String execute(){
		Map<String,String> map = Struct2Util.getReuqestParams();
		String method = map.get("method");
		System.out.println(map);
		if("regiest".equals(method)){
			String email = map.get("eMail");
			user = new User();
			user.setEmail(email);
			user.setName(map.get("userName"));
			user.setPassword(map.get("password"));
			regiest(user);
		}else if("checkExist".equals(method)){
			
		}
		return null;
	}
	
	
}
